package com.android.utils.watcher;

import android.text.Editable;
import android.text.TextWatcher;
import android.widget.Button;

import com.android.activity.LoginActivity;

public class MyWatcher implements TextWatcher {

    private Button getVerificationCode,registerButton;
    private LoginActivity loginActivity;

    public MyWatcher() {

    }

    public MyWatcher(Button getVerificationCode, Button registerButton, LoginActivity loginActivity) {
        this.getVerificationCode = getVerificationCode;
        this.registerButton = registerButton;
        this.loginActivity = loginActivity;
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        //当号码大于11位时显示按钮
        if(s.length()>=11){
            getVerificationCode.setEnabled(true);
            //注册按钮
            registerButton.setOnClickListener(loginActivity);
        }
        else {
            getVerificationCode.setEnabled(false);
        }

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        //当号码大于11位时显示按钮
        if(s.length()>=11){
            getVerificationCode.setEnabled(true);
            //注册按钮
            registerButton.setOnClickListener(loginActivity);
        }
        else {
            getVerificationCode.setEnabled(false);
        }

    }

    @Override
    public void afterTextChanged(Editable s) {

    }
}
